package com.example.minefieldkeepercloud.adapter;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;

import com.example.minefieldkeepercloud.R;

import com.example.minefieldkeepercloud.activity.machinerymaintain.MachineDetailAc;
import com.example.minefieldkeepercloud.bean.ListFmBean;
import com.king.base.adapter.ViewHolderAdapter;
import com.king.base.adapter.holder.ViewHolder;

import java.util.List;

public class ListFmAdapter extends ViewHolderAdapter<ListFmBean.DataBean> {
    private AppCompatActivity context;
    private String Date;
    public ListFmAdapter(AppCompatActivity context, List<ListFmBean.DataBean> listData) {
        super(context, listData);
        this.context = context;
    }

    @Override
    public View buildConvertView(LayoutInflater layoutInflater, ListFmBean.DataBean string, int position) {
        return inflate(R.layout.adapter_listfm);
    }

    @Override
    public void bindViewDatas(ViewHolder holder,final ListFmBean.DataBean bean, final int position) {


        holder.setText(R.id.tv_1, bean.getHandleUserName());
        holder.setText(R.id.tv_2, bean.getHl()+"");
        holder.setText(R.id.tv_3, bean.getWx()+"");
        holder.setText(R.id.tv_4, bean.getWh()+"");

        holder.getView(R.id.tv_2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MachineDetailAc.start(context,bean.getFactoryID()+"",bean.getHandleUserID()+"",Date,"3");
            }
        });

        holder.getView(R.id.tv_3).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MachineDetailAc.start(context,bean.getFactoryID()+"",bean.getHandleUserID()+"",Date,"2");
            }
        });

        holder.getView(R.id.tv_4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                MachineDetailAc.start(context,bean.getFactoryID()+"",bean.getHandleUserID()+"",Date,"4");
            }
        });

    }

    public void setDate(String Date)
    {
        this.Date=Date;
    }
}
